home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / usr / include / glib-2.0 / glib / gmarkup.h < prev    next >
Encoding:
C/C++ Source or Header  |  2006-04-25  |  5.1 KB  |  132 lines

  1. /* gmarkup.h - Simple XML-like string parser/writer
  2.  *
  3.  *  Copyright 2000 Red Hat, Inc.
  4.  *
  5.  * GLib is free software; you can redistribute it and/or modify it
  6.  * under the terms of the GNU Lesser General Public License as
  7.  * published by the Free Software Foundation; either version 2 of the
  8.  * License, or (at your option) any later version.
  9.  *
  10.  * GLib is distributed in the hope that it will be useful,
  11.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  13.  * Lesser General Public License for more details.
  14.  *
  15.  * You should have received a copy of the GNU Lesser General Public
  16.  * License along with GLib; see the file COPYING.LIB.  If not,
  17.  * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  18.  *   Boston, MA 02111-1307, USA.
  19.  */
  20.  
  21. #ifndef __G_MARKUP_H__
  22. #define __G_MARKUP_H__
  23.  
  24. #include <stdarg.h>
  25.  
  26. #include <glib/gerror.h>
  27.  
  28. G_BEGIN_DECLS
  29.  
  30. typedef enum
  31. {
  32.   G_MARKUP_ERROR_BAD_UTF8,
  33.   G_MARKUP_ERROR_EMPTY,
  34.   G_MARKUP_ERROR_PARSE,
  35.   /* These three are primarily intended for specific GMarkupParser
  36.    * implementations to set.
  37.    */
  38.   G_MARKUP_ERROR_UNKNOWN_ELEMENT,
  39.   G_MARKUP_ERROR_UNKNOWN_ATTRIBUTE,
  40.   G_MARKUP_ERROR_INVALID_CONTENT
  41. } GMarkupError;
  42.  
  43. #define G_MARKUP_ERROR g_markup_error_quark ()
  44.  
  45. GQuark g_markup_error_quark (void);
  46.  
  47. typedef enum
  48. {
  49.   /* Hmm, can't think of any at the moment */
  50.   G_MARKUP_DO_NOT_USE_THIS_UNSUPPORTED_FLAG = 1 << 0
  51.   
  52. } GMarkupParseFlags;
  53.  
  54. typedef struct _GMarkupParseContext GMarkupParseContext;
  55. typedef struct _GMarkupParser GMarkupParser;
  56.  
  57. struct _GMarkupParser
  58. {
  59.   /* Called for open tags <foo bar="baz"> */
  60.   void (*start_element)  (GMarkupParseContext *context,
  61.                           const gchar         *element_name,
  62.                           const gchar        **attribute_names,
  63.                           const gchar        **attribute_values,
  64.                           gpointer             user_data,
  65.                           GError             **error);
  66.  
  67.   /* Called for close tags </foo> */
  68.   void (*end_element)    (GMarkupParseContext *context,
  69.                           const gchar         *element_name,
  70.                           gpointer             user_data,
  71.                           GError             **error);
  72.  
  73.   /* Called for character data */
  74.   /* text is not nul-terminated */
  75.   void (*text)           (GMarkupParseContext *context,
  76.                           const gchar         *text,
  77.                           gsize                text_len,  
  78.                           gpointer             user_data,
  79.                           GError             **error);
  80.  
  81.   /* Called for strings that should be re-saved verbatim in this same
  82.    * position, but are not otherwise interpretable.  At the moment
  83.    * this includes comments and processing instructions.
  84.    */
  85.   /* text is not nul-terminated. */
  86.   void (*passthrough)    (GMarkupParseContext *context,
  87.                           const gchar         *passthrough_text,
  88.                           gsize                text_len,  
  89.                           gpointer             user_data,
  90.                           GError             **error);
  91.  
  92.   /* Called on error, including one set by other
  93.    * methods in the vtable. The GError should not be freed.
  94.    */
  95.   void (*error)          (GMarkupParseContext *context,
  96.                           GError              *error,
  97.                           gpointer             user_data);
  98. };
  99.  
  100. GMarkupParseContext *g_markup_parse_context_new   (const GMarkupParser *parser,
  101.                                                    GMarkupParseFlags    flags,
  102.                                                    gpointer             user_data,
  103.                                                    GDestroyNotify       user_data_dnotify);
  104. void                 g_markup_parse_context_free  (GMarkupParseContext *context);
  105. gboolean             g_markup_parse_context_parse (GMarkupParseContext *context,
  106.                                                    const gchar         *text,
  107.                                                    gssize               text_len,  
  108.                                                    GError             **error);
  109.                                                    
  110. gboolean             g_markup_parse_context_end_parse (GMarkupParseContext *context,
  111.                                                        GError             **error);
  112. G_CONST_RETURN gchar *g_markup_parse_context_get_element (GMarkupParseContext *context);
  113.  
  114. /* For user-constructed error messages, has no precise semantics */
  115. void                 g_markup_parse_context_get_position (GMarkupParseContext *context,
  116.                                                           gint                *line_number,
  117.                                                           gint                *char_number);
  118.  
  119. /* useful when saving */
  120. gchar* g_markup_escape_text (const gchar *text,
  121.                              gssize       length);  
  122.  
  123. gchar *g_markup_printf_escaped (const char *format,
  124.                 ...) G_GNUC_PRINTF (1, 2);
  125. gchar *g_markup_vprintf_escaped (const char *format,
  126.                  va_list     args);
  127.  
  128. G_END_DECLS
  129.  
  130. #endif /* __G_MARKUP_H__ */
  131.  
  132.